namespace Canlib
{

using System;
using System.Text;
using System.Runtime.InteropServices;



public class CanlibAPI
{

  public enum canStatus : int 
  {
      canOK                  = 0,
      canERR_PARAM           = -1, 
      canERR_NOMSG           = -2, 
      canERR_NOTFOUND        = -3, 
      canERR_NOMEM           = -4, 
      canERR_NOCHANNELS      = -5, 
      canERR_RESERVED_3      = -6, 
      canERR_TIMEOUT         = -7, 
      canERR_NOTINITIALIZED  = -8, 
      canERR_NOHANDLES       = -9, 
      canERR_INVHANDLE       = -10,
      canERR_INIFILE         = -11,
      canERR_DRIVER          = -12,
      canERR_TXBUFOFL        = -13,
      canERR_RESERVED_1      = -14,
      canERR_HARDWARE        = -15,
      canERR_DYNALOAD        = -16,
      canERR_DYNALIB         = -17,
      canERR_DYNAINIT        = -18,
      canERR_RESERVED_4      = -19,
      canERR_RESERVED_5      = -20,
      canERR_RESERVED_6      = -21,
      canERR_RESERVED_2      = -22,
      canERR_DRIVERLOAD      = -23,
      canERR_DRIVERFAILED    = -24,
      canERR_NOCONFIGMGR     = -25,
      canERR_NOCARD          = -26,
      canERR_RESERVED_7      = -27,
      canERR_REGISTRY        = -28,
      canERR_LICENSE         = -29,
      canERR_INTERNAL        = -30,
      canERR_NO_ACCESS       = -31,
      canERR__RESERVED       = -32
  }

  public const int WM__CANLIB                              = (0x400+16354);
  public const int canFILTER_ACCEPT                        = 1;
  public const int canFILTER_REJECT                        = 2;
  public const int canFILTER_SET_CODE_STD                  = 3;
  public const int canFILTER_SET_MASK_STD                  = 4;
  public const int canFILTER_SET_CODE_EXT                  = 5;
  public const int canFILTER_SET_MASK_EXT                  = 6;
  public const int canFILTER_NULL_MASK                     = 0;
  public const int canDRIVER_NORMAL                        = 4;
  public const int canDRIVER_SILENT                        = 1;
  public const int canDRIVER_SELFRECEPTION                 = 8;
  public const int canDRIVER_OFF                           = 0;
  public const int BAUD_1M                                 = (-1);
  public const int BAUD_500K                               = (-2);
  public const int BAUD_250K                               = (-3);
  public const int BAUD_125K                               = (-4);
  public const int BAUD_100K                               = (-5);
  public const int BAUD_62K                                = (-6);
  public const int BAUD_50K                                = (-7);
  public const int canIOCTL_PREFER_EXT                     = 1;
  public const int canIOCTL_PREFER_STD                     = 2;
  public const int canIOCTL_CLEAR_ERROR_COUNTERS           = 5;
  public const int canIOCTL_SET_TIMER_SCALE                = 6;
  public const int canIOCTL_SET_TXACK                      = 7;
  public const int canCHANNELDATA_CHANNEL_CAP              = 1;
  public const int canCHANNELDATA_TRANS_CAP                = 2;
  public const int canCHANNELDATA_CHANNEL_FLAGS            = 3;
  public const int canCHANNELDATA_CARD_TYPE                = 4;
  public const int canCHANNELDATA_CARD_NUMBER              = 5;
  public const int canCHANNELDATA_CHAN_NO_ON_CARD          = 6;
  public const int canCHANNELDATA_CARD_SERIAL_NO           = 7;
  public const int canCHANNELDATA_TRANS_SERIAL_NO          = 8;
  public const int canCHANNELDATA_CARD_FIRMWARE_REV        = 9;
  public const int canCHANNELDATA_CARD_HARDWARE_REV        = 10;
  public const int canCHANNELDATA_CARD_UPC_NO              = 11;
  public const int canCHANNELDATA_TRANS_UPC_NO             = 12;
  public const int canCHANNELDATA_CHANNEL_NAME             = 13;
  public const int canCHANNELDATA_DLL_FILE_VERSION         = 14;
  public const int canCHANNELDATA_DLL_PRODUCT_VERSION      = 15;
  public const int canCHANNELDATA_DLL_FILETYPE             = 16;
  public const int canCHANNELDATA_TRANS_TYPE               = 17;
  public const int canCHANNELDATA_DEVICE_PHYSICAL_POSITION = 18;
  public const int canCHANNELDATA_UI_NUMBER                = 19;
  public const int canCHANNELDATA_TIMESYNC_ENABLED         = 20;
  public const int canCHANNELDATA_DRIVER_FILE_VERSION      = 21;
  public const int canCHANNELDATA_DRIVER_PRODUCT_VERSION   = 22;
  public const int canCHANNELDATA_MFGNAME_UNICODE          = 23;
  public const int canCHANNELDATA_MFGNAME_ASCII            = 24;
  public const int canCHANNELDATA_DEVDESCR_UNICODE         = 25;
  public const int canCHANNELDATA_DEVDESCR_ASCII           = 26;
  public const int canCHANNEL_IS_EXCLUSIVE                 = 0x0001;
  public const int canCHANNEL_IS_OPEN                      = 0x0002;
  public const int canHWTYPE_NONE                          = 0;
  public const int canHWTYPE_VIRTUAL                       = 1;
  public const int canHWTYPE_LAPCAN                        = 2;
  public const int canHWTYPE_CANPARI                       = 3;
  public const int canHWTYPE_PCCAN                         = 8;
  public const int canHWTYPE_PCICAN                        = 9;
  public const int canHWTYPE_USBCAN                        = 11;
  public const int canHWTYPE_PCICAN_II                     = 40;
  public const int canHWTYPE_USBCAN_II                     = 42;
  public const int canHWTYPE_SIMULATED                     = 44;
  public const int canHWTYPE_ACQUISITOR                    = 46;
  public const int canHWTYPE_LEAF                          = 48;
  public const int canHWTYPE_PC104_PLUS                    = 50;
  public const int canHWTYPE_PCICANX_II                    = 52;
  public const int canHWTYPE_MEMORATOR_PRO                 = 54;
  public const int canHWTYPE_USBCAN_PRO                    = 56;
  public const int canHWTYPE_IRIS                          = 58;
  public const int canCHANNEL_CAP_EXTENDED_CAN             = 0x00000001;
  public const int canCHANNEL_CAP_BUS_STATISTICS           = 0x00000002;
  public const int canCHANNEL_CAP_ERROR_COUNTERS           = 0x00000004;
  public const int canCHANNEL_CAP_CAN_DIAGNOSTICS          = 0x00000008;
  public const int canCHANNEL_CAP_GENERATE_ERROR           = 0x00000010;
  public const int canCHANNEL_CAP_GENERATE_OVERLOAD        = 0x00000020;
  public const int canCHANNEL_CAP_TXREQUEST                = 0x00000040;
  public const int canCHANNEL_CAP_TXACKNOWLEDGE            = 0x00000080;
  public const int canCHANNEL_CAP_VIRTUAL                  = 0x00010000;
  public const int canCHANNEL_CAP_SIMULATED                = 0x00020000;
  public const int canDRIVER_CAP_HIGHSPEED                 = 0x00000001;
  public const int canIOCTL_GET_RX_BUFFER_LEVEL            = 8;
  public const int canIOCTL_GET_TX_BUFFER_LEVEL            = 9;
  public const int canIOCTL_FLUSH_RX_BUFFER                = 10;
  public const int canIOCTL_FLUSH_TX_BUFFER                = 11;
  public const int canIOCTL_GET_TIMER_SCALE                = 12;
  public const int canIOCTL_SET_TXRQ                       = 13;
  public const int canIOCTL_GET_EVENTHANDLE                = 14;
  public const int canIOCTL_SET_BYPASS_MODE                = 15;
  public const int canIOCTL_SET_WAKEUP                     = 16;
  public const int canIOCTL_GET_DRIVERHANDLE               = 17;
  public const int canIOCTL_MAP_RXQUEUE                    = 18;
  public const int canIOCTL_GET_WAKEUP                     = 19;
  public const int canIOCTL_SET_REPORT_ACCESS_ERRORS       = 20;
  public const int canIOCTL_GET_REPORT_ACCESS_ERRORS       = 21;
  public const int canIOCTL_CONNECT_TO_VIRTUAL_BUS         = 22;
  public const int canIOCTL_DISCONNECT_FROM_VIRTUAL_BUS    = 23;
  public const int canIOCTL_SET_USER_IOPORT                = 24;
  public const int canIOCTL_GET_USER_IOPORT                = 25;
  public const int canVERSION_CANLIB32_VERSION             = 0;
  public const int canVERSION_CANLIB32_PRODVER             = 1;
  public const int canOBJBUF_TYPE_AUTO_RESPONSE            = 0x01;
  public const int canOBJBUF_TYPE_PERIODIC_TX              = 0x02;
  public const int canOBJBUF_AUTO_RESPONSE_RTR_ONLY        = 0x01;
  public const int canEVENT_RX             = 32000;
  public const int canEVENT_TX             = 32001;
  public const int canEVENT_ERROR          = 32002;
  public const int canEVENT_STATUS         = 32003;
  public const int canNOTIFY_NONE          = 0;
  public const int canNOTIFY_RX            = 0x0001;
  public const int canNOTIFY_TX            = 0x0002;
  public const int canNOTIFY_ERROR         = 0x0004;
  public const int canNOTIFY_STATUS        = 0x0008;
  public const int canSTAT_ERROR_PASSIVE   = 0x00000001;
  public const int canSTAT_BUS_OFF         = 0x00000002;
  public const int canSTAT_ERROR_WARNING   = 0x00000004;
  public const int canSTAT_ERROR_ACTIVE    = 0x00000008;
  public const int canSTAT_TX_PENDING      = 0x00000010;
  public const int canSTAT_RX_PENDING      = 0x00000020;
  public const int canSTAT_RESERVED_1      = 0x00000040;
  public const int canSTAT_TXERR           = 0x00000080;
  public const int canSTAT_RXERR           = 0x00000100;
  public const int canSTAT_HW_OVERRUN      = 0x00000200;
  public const int canSTAT_SW_OVERRUN      = 0x00000400;
  public const int canSTAT_OVERRUN         = (canSTAT_HW_OVERRUN | canSTAT_SW_OVERRUN);
  public const int canMSG_MASK             = 0x00ff;
  public const int canMSG_RTR              = 0x0001;
  public const int canMSG_STD              = 0x0002;
  public const int canMSG_EXT              = 0x0004;
  public const int canMSG_WAKEUP           = 0x0008;
  public const int canMSG_NERR             = 0x0010;
  public const int canMSG_ERROR_FRAME      = 0x0020;
  public const int canMSG_TXACK            = 0x0040;
  public const int canMSG_TXRQ             = 0x0080;
  public const int canMSGERR_MASK          = 0xff00;
  public const int canMSGERR_HW_OVERRUN    = 0x0200;
  public const int canMSGERR_SW_OVERRUN    = 0x0400;
  public const int canMSGERR_STUFF         = 0x0800;
  public const int canMSGERR_FORM          = 0x1000;
  public const int canMSGERR_CRC           = 0x2000;
  public const int canMSGERR_BIT0          = 0x4000;
  public const int canMSGERR_BIT1          = 0x8000;
  public const int canMSGERR_OVERRUN       = 0x0600;
  public const int canMSGERR_BIT           = 0xC000;
  public const int canMSGERR_BUSERR        = 0xF800;
  public const int canTRANSCEIVER_LINEMODE_NA          =   0;
  public const int canTRANSCEIVER_LINEMODE_SWC_SLEEP   =   4;
  public const int canTRANSCEIVER_LINEMODE_SWC_NORMAL  =   5;
  public const int canTRANSCEIVER_LINEMODE_SWC_FAST    =   6;
  public const int canTRANSCEIVER_LINEMODE_SWC_WAKEUP  =   7;
  public const int canTRANSCEIVER_LINEMODE_SLEEP       =   8;
  public const int canTRANSCEIVER_LINEMODE_NORMAL      =   9;
  public const int canTRANSCEIVER_LINEMODE_STDBY       =  10;
  public const int canTRANSCEIVER_LINEMODE_TT_CAN_H    =  11;
  public const int canTRANSCEIVER_LINEMODE_TT_CAN_L    =  12;
  public const int canTRANSCEIVER_LINEMODE_OEM1        =  13;
  public const int canTRANSCEIVER_LINEMODE_OEM2        =  14;
  public const int canTRANSCEIVER_LINEMODE_OEM3        =  15;
  public const int canTRANSCEIVER_LINEMODE_OEM4        =  16;
  public const int canTRANSCEIVER_RESNET_NA            = 0;
  public const int canTRANSCEIVER_RESNET_MASTER        = 1;
  public const int canTRANSCEIVER_RESNET_MASTER_STBY   = 2;
  public const int canTRANSCEIVER_RESNET_SLAVE         = 3;
  public const int canTRANSCEIVER_TYPE_UNKNOWN         =   0;
  public const int canTRANSCEIVER_TYPE_251             =   1;
  public const int canTRANSCEIVER_TYPE_252             =   2;
  public const int canTRANSCEIVER_TYPE_DNOPTO          =   3;
  public const int canTRANSCEIVER_TYPE_W210            =   4;
  public const int canTRANSCEIVER_TYPE_SWC_PROTO       =   5;
  public const int canTRANSCEIVER_TYPE_SWC             =   6;
  public const int canTRANSCEIVER_TYPE_EVA             =   7;
  public const int canTRANSCEIVER_TYPE_FIBER           =   8;
  public const int canTRANSCEIVER_TYPE_K251            =   9;
  public const int canTRANSCEIVER_TYPE_K               =  10;
  public const int canTRANSCEIVER_TYPE_1054_OPTO       =  11;
  public const int canTRANSCEIVER_TYPE_SWC_OPTO        =  12;
  public const int canTRANSCEIVER_TYPE_TT              =  13;
  public const int canTRANSCEIVER_TYPE_1050            =  14;
  public const int canTRANSCEIVER_TYPE_1050_OPTO       =  15;
  public const int canTRANSCEIVER_TYPE_1041            =  16;
  public const int canTRANSCEIVER_TYPE_1041_OPTO       =  17;
  public const int canTRANSCEIVER_TYPE_RS485           =  18;
  public const int canTRANSCEIVER_TYPE_LIN             =  19;
  public const int canTRANSCEIVER_TYPE_KONE            =  20;

  public const int canWANT_EXCLUSIVE            = 0x0008;
  public const int canWANT_EXTENDED             = 0x0010;
  public const int canWANT_VIRTUAL              = 0x0020;
  public const int canOPEN_EXCLUSIVE            = canWANT_EXCLUSIVE;
  public const int canOPEN_REQUIRE_EXTENDED     = canWANT_EXTENDED;
  public const int canOPEN_ACCEPT_VIRTUAL       = canWANT_VIRTUAL;
  public const int canOPEN_OVERRIDE_EXCLUSIVE   = 0x0040;
  public const int canOPEN_REQUIRE_INIT_ACCESS  = 0x0080;
  public const int canOPEN_NO_INIT_ACCESS       = 0x0100;


  [ StructLayout(LayoutKind.Sequential)]
  public struct canUserIoPortData {
    public uint portNo;
    public uint portValue;
  } 


  [DllImport("canlib32.dll")]
  public static extern void canInitializeLibrary();

  [DllImport("canlib32.dll")]
  public static extern canStatus canClose(int handle);

  [DllImport("canlib32.dll")]
  public static extern canStatus canBusOn(int handle);

  [DllImport("canlib32.dll")]
  public static extern canStatus canBusOff(int handle);

  [DllImport("canlib32.dll")]
  public static extern canStatus canSetBusParams(int handle,
    int freq,
    uint tseg1,
    uint tseg2,
    uint sjw,
    uint noSamp,
    uint syncmode);

  [DllImport("canlib32.dll")]
  public static extern canStatus canGetBusParams(int handle,
    ref int freq,
    ref uint tseg1,
    ref uint tseg2,
    ref uint sjw,
    ref uint noSamp,
    ref uint syncmode);

  [DllImport("canlib32.dll")]
  public static extern canStatus canSetBusOutputControl(int handle,
    uint drivertype);

  [DllImport("canlib32.dll")]
  public static extern canStatus canGetBusOutputControl(int handle,
    ref uint drivertype);

  [DllImport("canlib32.dll")]
  public static extern canStatus canAccept(int handle,
                                           int envelope,
                                           uint flag);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadStatus(int handle,
                                               ref uint flags);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadErrorCounters(int handle,
    ref uint txErr,
    ref uint rxErr,
    ref uint ovErr);

  [DllImport("canlib32.dll")]
  public static extern canStatus canWrite(int handle, int id,
    byte [] msg,
    uint dlc, uint flag);

  [DllImport("canlib32.dll")]
  public static extern canStatus canWriteSync(int handle, uint timeout);

  [DllImport("canlib32.dll")]
  public static extern canStatus canRead(int handle,
                                         out int id,
                                         byte [] msg,
                                         out uint dlc,
                                         out uint flag,
                                         out uint time);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadWait(int handle,
                                             out int id,
                                             byte [] msg,
                                             out uint dlc,
                                             out uint flag,
                                             out uint time,
                                             uint timeout);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadSpecific(int handle, 
    int id, 
    byte [] msg,
    out uint dlc,
    out uint flag,
    out uint time);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadSync(int handle, uint timeout);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadSyncSpecific(int handle, int id, uint timeout);

  [DllImport("canlib32.dll")]
  public static extern canStatus canReadSpecificSkip(int hnd,
    int id,
    byte [] msg,
    out uint dlc,
    out uint flag,
    out uint time);

  [DllImport("canlib32.dll")]
  public static extern canStatus canSetNotify(int handle, int aHWnd, uint aNotifyFlags);

  [DllImport("canlib32.dll")]
  public static extern canStatus canTranslateBaud(ref int freq,
    ref uint tseg1,
    ref uint tseg2,
    ref uint sjw,
    ref uint nosamp,
    ref uint syncMode);

  [DllImport("canlib32.dll", CharSet=CharSet.Ansi, EntryPoint="canGetErrorText")]
  public static extern canStatus _canGetErrorText(canStatus err, 
    StringBuilder buf,
    uint bufsiz);

  public static canStatus canGetErrorText(canStatus err, ref String buf)
  {
    StringBuilder b = new StringBuilder(100);
    canStatus stat;
    stat = _canGetErrorText(err, b, (uint)b.Capacity);
    buf = b.ToString();
    return stat;
  }

  [DllImport("canlib32.dll")]
  public static extern ushort canGetVersion();

  [DllImport("canlib32.dll", EntryPoint="canIoCtl")]
  public static extern canStatus _canIoCtl_uint(int handle, uint func,
    ref uint buf,
    uint buflen);

  public static canStatus canIoCtl(int handle, uint func, ref uint val)
  {
    canStatus stat = _canIoCtl_uint(handle, func, ref val, 4);
    return stat;
  }

  [DllImport("canlib32.dll", EntryPoint="canIoCtl")]
  public static extern canStatus _canIoCtl_uipd(int handle,
                                                uint func,
                                                ref canUserIoPortData buf,
                                                uint buflen);

  public static canStatus canIoCtl(int handle, uint func, ref canUserIoPortData val)
  {
    canStatus stat = _canIoCtl_uipd(handle, func, ref val, 8);
    return stat;
  }
  

  [DllImport("canlib32.dll")]
  public static extern uint canReadTimer(int hnd);

  [DllImport("canlib32.dll")]
  public static extern int canOpenChannel(int channel, int flags);

  [DllImport("canlib32.dll")]
  public static extern canStatus canGetNumberOfChannels(ref int channelCount);

  [DllImport("canlib32.dll", EntryPoint="canGetChannelData")]
  public static extern canStatus _canGetChannelData_uint(int channel,
    int item, 
    ref uint data,
    uint bufsize);

  [DllImport("canlib32.dll", EntryPoint="canGetChannelData")]
  public static extern canStatus _canGetChannelData_uquad(int channel,
    int item, 
    ref ulong data,
    uint bufsize);

  [DllImport("canlib32.dll", CharSet=CharSet.Ansi, EntryPoint="canGetChannelData")]
  public static extern canStatus _canGetChannelData_ansistring(int channel,
    int item, 
    StringBuilder buf,
    uint bufsize);
  
  public static canStatus canGetChannelData(int channel, int item, ref uint data)
  {
    return _canGetChannelData_uint(channel, item, ref data, 4);
  }
  
  public static canStatus canGetChannelData(int channel, int item, ref ulong data)
  {
    return _canGetChannelData_uquad(channel, item, ref data, 8);
  }

  public static canStatus canGetChannelData(int channel, int item, ref String data)
  {
    StringBuilder b = new StringBuilder(1024);
    canStatus stat = _canGetChannelData_ansistring(channel, item, b, (uint)b.Capacity);
    data = b.ToString();
    return stat;
  }  

  /*[DllImport("canlib32.dll")]
  public static extern canStatus canReadEvent(int hnd, CanEvent *event);*/

  [DllImport("canlib32.dll")]
  public static extern canStatus canWaitForEvent(int hnd, uint timeout);

  [DllImport("canlib32.dll")]
  public static extern canStatus canSetBusParamsC200(int hnd, byte btr0, byte btr1);

  [DllImport("canlib32.dll")]
  public static extern canStatus canSetDriverMode(int hnd, int lineMode, int resNet);

  [DllImport("canlib32.dll")]
  public static extern canStatus canGetDriverMode(int hnd, ref int lineMode, ref int resNet);
  
  [DllImport("canlib32.dll")]
  public static extern uint canGetVersionEx(uint itemCode);

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamGetCount ();

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamCommitChanges ();

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamDeleteEntry (int index);

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamCreateNewEntry ();

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamSwapEntries (int index1, int index2);

  [DllImport("canlib32.dll", CharSet=CharSet.Ansi, EntryPoint="canParamGetName")]
  public static extern canStatus _canParamGetName (int index,
      StringBuilder buffer,
      int maxlen);

  public static canStatus canParamGetName (int index,
    ref String buffer,
    int maxlen)
  {
    StringBuilder b = new StringBuilder(1000);
    canStatus stat;
    stat = _canParamGetName(index, b, b.Capacity);
    buffer = b.ToString();
    return stat;
  }  

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamGetChannelNumber (int index);

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamGetBusParams (int index,
    ref int bitrate,
    ref uint tseg1,
    ref uint tseg2,
    ref uint sjw,
    ref uint noSamp);

  [DllImport("canlib32.dll", CharSet=CharSet.Ansi, EntryPoint="canParamSetName")]
  public static extern canStatus _canParamSetName (int index, StringBuilder buffer);

  public static canStatus canParamSetName (int index, String buffer)
  {
    StringBuilder b = new StringBuilder(buffer);
    canStatus stat = _canParamSetName(index, b);
    return stat;
  }

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamSetChannelNumber (int index, int channel);

  [DllImport("canlib32.dll")]
  public static extern canStatus canParamSetBusParams (int index,
    int bitrate,
    uint tseg1,
    uint tseg2,
    uint sjw,
    uint noSamp);

  [DllImport("canlib32.dll", CharSet=CharSet.Ansi, EntryPoint="canParamFindByName")]
  public static extern canStatus _canParamFindByName (StringBuilder name); 

  public static canStatus canParamFindByName (String name)
  {
    StringBuilder b = new StringBuilder(name);
    canStatus stat = _canParamFindByName(b);
    return stat;
  }
  
  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufFreeAll(int handle);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufAllocate(int handle, int type);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufFree(int handle, int idx);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufWrite(int handle, int idx, int id, 
    byte [] msg,
    uint dlc, uint flags);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufSetFilter(int handle, int idx,
    uint code, uint mask);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufSetFlags(int handle, int idx, uint flags);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufEnable(int handle, int idx);

  [DllImport("canlib32.dll")]
  public static extern canStatus canObjBufDisable(int handle, int idx);




}



}

